package fr.cnam.ratpProject.client.activities.home;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.IsWidget;

import fr.cnam.ratpProject.client.activities.itinarySearch.ItinarySearchPlace;
import fr.cnam.ratpProject.client.activities.lineMap.LineMapPlace;
import fr.cnam.ratpProject.client.activities.searchStation.SearchStationPlace;
import fr.cnam.ratpProject.client.utils.GlueProvider;
import fr.cnam.ratpProject.client.utils.RatpActivity;
import fr.cnam.ratpProject.client.utils.RatpCommand;

public class HomeActivity extends RatpActivity{

	public interface HomeView extends IsWidget
	{
		void setActionCommand(RatpCommand<Action> command);
	}
	
	private HomeView view;
	protected enum Action {
		PLAN,CLASSEMENT,ITINERAIRE,INFOS,STATION
	}
	
	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		view = GlueProvider.INSTANCE.getClientFactory().getHomeView();
		attachView(panel, view);
		view.setActionCommand(new RatpCommand<Action>() {
			@Override
			public void execute(Action data) {
				//TODO
				switch(data)
				{
					case STATION : 
 						goTo(new SearchStationPlace("SearchStation"));
 						break;
					case PLAN : 
						goTo(new LineMapPlace("LineMap"));						
						break;
					case ITINERAIRE : 
						goTo(new ItinarySearchPlace("ItinarySearch"));
						break;
					case CLASSEMENT : 
						goTo(new SearchStationPlace("SearchStation",true));
						break;
					default:
						break;
				}
			}
		});
	}

}
